$(function () {
    obj.init();
});

var obj = new function () {
    'use strict';
    return {
        dataGrid: null,
        userId:null,
        params: {
        },
        init: function () {
            this.userId = xhTool.getQuery('userId');
            this.listener();
        },
        listener: function () {
            var $this = this;
            var histroyHtml='';
            var repairHtml='';
            xhExtra.ajaxRequest('User/getDevice' , {id: $this.userId}, {}, function(data) {
                 $.each(data, function (i, history) {
                     histroyHtml +="<tr bgcolor=\"#ffffff\"><td>"+history.type+"</td>\n" +
                         "        <td>"+history.devNumber+"</td>\n" +
                         "        <td>"+history.long+"</td>\n" +
                         "        <td>"+history.start+"</td>\n" +
                         "        <td>"+history.end+"</td></tr>"
                 });
                 $("#deviceHistory").append(histroyHtml);
            });
            xhExtra.ajaxRequest('User/getRepair' , {id: $this.userId}, {}, function(data) {
                $.each(data, function (i, repair) {
                    repairHtml +="<tr  bgcolor=\"#ffffff\"><td>"+ repair.sRepairProjectName+"</td>\n" +
                         "        <td>"+repair.sDeviceNumber+"</td>\n" +
                         "        <td>"+repair.sNewDeviceNumber+"</td>\n" +
                         "        <td>"+repair.sStartDate+"</td>\n" +
                         "        <td>"+repair.sEndDate+"</td></tr>"
                 });
                 $("#repairHistory").append(repairHtml);
            });
            $("#repairBtn").click(function () {
                $this.funObj().repairBtn();
            })
        },
        funObj: function () {
            var $this = this;
            return {
                repairBtn:function () {
                    // console.log(baseUrl);
                    window.top.xhTop.createNewTab('维修详情',baseUrl+'device/repairDeviceInfo?userId='+$this.userId);
                }
            }
        }
    }
};